home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / incoming / jstools-.6v3 / jstools- / jstools-tk3.6v3.0 / lib / jentryvi.tcl < prev    next >
Encoding:
Text File  |  1995-02-05  |  4.6 KB  |  189 lines

  1. # jentryvi.tcl - support for vi Entry bindings
  2. # Copyright 1992-1994 by Jay Sekora.  All rights reserved, except 
  3. # that this file may be freely redistributed in whole or in part 
  4. # for non-profit, noncommercial use.
  5.  
  6. ######################################################################
  7. # j:eb:vi_init - initialise info for vi Entry bindings
  8. ######################################################################
  9.  
  10. proc j:eb:vi_init { e } {
  11.   global j_teb
  12.   set j_teb(cutbuffer) {}
  13.   set j_teb(dragscroll,txnd) 0
  14.   set j_teb(dragscroll,delay) 50
  15.   set j_teb(scanpaste_time) 0
  16.   set j_teb(scanpaste_paste) 1
  17.   
  18.   set j_teb(keymap,$e) vi-insert    ;# annoying to start in command mode!
  19.   
  20.   # in tk4, we need to make sure tkTextBind is called _before_
  21.   #   j:eb:key_bind!
  22.   j:tk4 {tkEntryBind Enter}
  23.   
  24.   j:eb:key_bind $e
  25.   j:eb:mouse_bind $e
  26.   
  27.   j:ekb:mkmap Entry vi-command vi-command {
  28.     {Control-slash        j:eb:select_all}
  29.     {Control-backslash        j:eb:clear_selection}
  30.     
  31.     {Delete            j:ekb:left}
  32.     {BackSpace            j:ekb:left}
  33.     {space            j:ekb:right}
  34.     {minus            j:eb:beep}
  35.     {plus            j:eb:beep}
  36.     {Return            j:eb:beep}
  37.     
  38.     {Up                j:eb:beep}
  39.     {Down            j:eb:beep}
  40.     {Left            j:ekb:left}
  41.     {Right            j:ekb:right}
  42.     
  43.     {Control-p            j:eb:beep}
  44.     {Control-n            j:eb:beep}
  45.  
  46.     {k                j:eb:beep}
  47.     {j                j:eb:beep}
  48.     {h                j:ekb:left}
  49.     {l                j:ekb:right}
  50.  
  51.     {Control-k            j:eb:beep}
  52.     {Control-j            j:eb:beep}
  53.     {Control-h            j:ekb:left}
  54.     {Control-l            j:ekb:right}
  55.     
  56.     {Control-b            j:eb:beep}
  57.     {Control-f            j:eb:beep}
  58.  
  59.     {x                j:ekb:delete_right}
  60.     {X                j:ekb:delete_left}
  61.     {b                j:ekb:word_left}
  62.     {B                j:ekb:word_left}
  63.     {e_XXX            j:ekb:vi:word_end}
  64.     {w                j:ekb:word_right}
  65.     {W                j:ekb:word_right}
  66.     {G                j:eb:beep}
  67.     
  68.     {i                j:ekb:vi:insert}
  69.     {a                j:ekb:vi:append}
  70.     {I                j:ekb:vi:insert-bol}
  71.     {A                j:ekb:vi:append-eol}
  72.     {o                j:eb:beep}
  73.     {O                j:eb:beep}
  74.     
  75.     {asciicircum        j:ekb:bol}
  76.     {dollar            j:ekb:vi:eol}
  77.     {Home            j:ekb:bol}
  78.     {End            j:ekb:vi:eol}
  79.     
  80.     {Escape            j:eb:beep}
  81.     {Control-bracketleft    j:eb:beep}
  82.     
  83.     {Control-DEFAULT        j:eb:beep}
  84.     {DEFAULT            j:eb:beep}
  85.     {Shift-DEFAULT        j:eb:beep}
  86.   }
  87.   
  88.   j:ekb:mkmap Entry vi-insert vi-insert {
  89.     {Control-slash        j:eb:select_all}
  90.     {Control-backslash        j:eb:clear_selection}
  91.     
  92.     {Delete            j:ekb:delete_left}
  93.     {BackSpace            j:ekb:delete_left}
  94.     
  95.     {Control-i            j:ekb:self_insert}
  96.     {Control-j            j:ekb:self_insert}
  97.     {Control-h            j:ekb:delete_left}
  98.     
  99.     {Control-w            j:ekb:delete_word_left}
  100.     {Control-u            j:ekb:vi:delete_left_line}
  101.     
  102.     {Escape            j:ekb:vi:command}
  103.     {Control-bracketleft    j:ekb:vi:command}
  104.     
  105.     {Control-v            j:ekb:new_mode vi-literal}
  106.     
  107.     {Control-DEFAULT        j:eb:beep}
  108.     {DEFAULT            j:ekb:self_insert}
  109.     {Shift-DEFAULT        j:ekb:self_insert}
  110.   }
  111.   
  112.   j:ekb:mkmap Entry vi-literal vi-insert {
  113.     {DEFAULT            j:ekb:self_insert}
  114.     {Shift-DEFAULT        j:ekb:self_insert}
  115.     {Control-DEFAULT        j:ekb:self_insert}
  116.     {Meta-DEFAULT        j:ekb:self_insert}
  117.   }
  118. }
  119.  
  120. ######################################################################
  121. ###  VI COMMANDS
  122. ######################################################################
  123.  
  124. proc j:ekb:vi:command { W K A } {
  125.   j:ekb:left $W "" ""
  126.   j:ekb:new_mode vi-command $W $K $A
  127. }
  128.  
  129. proc j:ekb:vi:insert { W K A } {
  130.   j:ekb:new_mode vi-insert $W $K $A
  131. }
  132.  
  133. proc j:ekb:vi:eol { W K A } {
  134.   $W icursor [expr {[$W index end] - 1}]
  135.   j:ek:see_insert $W
  136. }
  137.  
  138. proc j:ekb:vi:append { W K A } {
  139.   global j_teb
  140.   # BOGUS - crosses newline boundaries
  141.   j:ekb:right $W $K $A
  142.   j:ekb:vi:insert $W $K $A
  143. }
  144.  
  145. proc j:ekb:vi:insert-bol { W K A } {
  146.   global j_teb
  147.   # BOGUS - bgg of line, not bgg of printable line
  148.   j:ekb:bol $W $K $A
  149.   j:ekb:vi:insert $W $K $A
  150. }
  151.  
  152. proc j:ekb:vi:append-eol { W K A } {
  153.   global j_teb
  154.   j:ekb:eol $W $K $A
  155.   j:ekb:vi:insert $W $K $A
  156. }
  157.  
  158. ######################################################################
  159. # used for Control-u in insert mode:
  160.  
  161. proc j:ekb:vi:delete_left_line { W K A } {
  162.   $W delete 0 insert
  163. }
  164.  
  165. ######################################################################
  166. # deprecated alias for backward compatibility:
  167. ######################################################################
  168.  
  169. proc j:eb:vi_bind { W } {
  170.   j:eb:vi_init $W
  171. }
  172.  
  173. ######################################################################
  174. # NOT YET WRITTEN:
  175. ######################################################################
  176.  
  177. # \
  178. proc NOT_YET_WRITTEN: {} {}
  179.  
  180. proc j:ekb:vi:word_end { W K A } {}
  181. proc j:ekb:vi:bol { W K A } {}
  182. proc j:ekb:vi:dd { W K A } {}
  183. proc j:ekb:vi:dw { W K A } {}
  184. proc j:ekb:vi:d-eol { W K A } {}
  185. proc j:ekb:vi:cc { W K A } {}
  186. proc j:ekb:vi:cw { W K A } {}
  187. proc j:ekb:vi:c-eol { W K A } {}
  188.